﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;

namespace Acme.BookStore
{
    public class BookStoreDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IRepository<Book, Guid> _bookRepository;
        private readonly IGuidGenerator _guidGenerator;
        public BookStoreDataSeedContributor(IRepository<Book, Guid> bookRepository,
            IGuidGenerator guidGenerator)
        {
            _bookRepository = bookRepository;
            _guidGenerator = guidGenerator;
        }
        public async Task SeedAsync(DataSeedContext context)
        {
            //throw new NotImplementedException();
            await _bookRepository.InsertAsync(new Book(_guidGenerator.Create())
            {
                Name = "test book 1",
                Type = BookType.Adventure,
                PublishDate = new DateTime(2019, 10, 19),
                Price = 21
            });
            await _bookRepository.InsertAsync(new Book(_guidGenerator.Create())
            {
                Name = "test book 2",
                Type = BookType.Adventure,
                PublishDate = new DateTime(2018, 12, 19),
                Price = 30
            });
        }
    }
}
